home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / GMS / Source / C / lib / gms.s < prev   
Encoding:
Text File  |  1997-04-28  |  1.7 KB  |  78 lines

  1. ;=======T=======T========================T==========================================;
  2. ;gms.s
  3. ;-----
  4. ;Compile this file and store it in SC:LIB/ if you have SAS/C.
  5. ;
  6. ;You can use it to take advantage of the multi-platform capabilities of GMS
  7. ;by linking your C programs with the following:
  8. ;
  9. ;  1> sc <source.c> link startup=LIB:gms.o data=far
  10.  
  11.     INCDIR    "INCLUDES:"
  12.     INCLUDE    "games/games_lib.i"
  13.  
  14. CALL    MACRO
  15.     jsr    _LVO\1(a6)
  16.     ENDM
  17.  
  18.     xdef    _GMSBase
  19.  
  20.     xref    _main
  21.     xref    _PREFSNAME
  22.  
  23.     SECTION    IceAssembler,CODE    ;SECTION __MERGED,CODE
  24.  
  25. ;===================================================================================;
  26. ;                            SPECIAL STARTUP CODE
  27. ;===================================================================================;
  28.  
  29. Start:    MOVEM.L    D0-D7/A0-A6,-(SP)
  30.     cmp.l    #"GMSP",d0
  31.     beq.s    .StartFromGMS
  32. .StartFromDOS
  33.     move.l    ($4).w,a6    ;a6 = ExecBase
  34.     lea    GMSName(pc),a1    ;a1 = Library name.
  35.     moveq    #$00,d0    ;d0 = Any version.
  36.     jsr    -552(a6)    ;>> = OpenLibrary()
  37.     move.l    d0,_GMSBase    ;ma = Save base.
  38.     beq.s    .errgms    ;>> = Error, exit.
  39.     move.l    d0,a6    ;a6 = GMSBase.
  40.     lea    .exit(pc),a0    ;a0 = Pointer to SelfDestruct() cleanup.
  41.     move.l    a7,a1    ;a1 = Stack pointer.
  42.     CALL    InitDestruct    ;>> = Initialise the call.
  43.  
  44.     move.l    _PREFSNAME,a0
  45.     CALL    SetUserPrefs
  46.     tst.l    d0
  47.     bne.s    .exit
  48.  
  49.     jsr    _main
  50.  
  51.     bra.s    .exit
  52.  
  53. .StartFromGMS
  54.     move.l    a1,_GMSBase
  55.     move.l    a1,a6    ;a6 = GMSBase.
  56.     lea    .exit(pc),a0    ;a0 = Pointer to SelfDestruct() cleanup.
  57.     move.l    a7,a1    ;a1 = Stack pointer.
  58.     CALL    InitDestruct    ;>> = Initialise the call.
  59.  
  60.     move.l    _PREFSNAME,a0
  61.     CALL    SetUserPrefs
  62.     tst.l    d0
  63.     bne.s    .exit
  64.  
  65.     jsr    _main
  66.  
  67. .exit    move.l    _GMSBase(pc),a6
  68.     CALL    CloseGMS
  69. .errgms    MOVEM.L    (SP)+,D0-D7/A0-A6
  70.     moveq    #$00,d0
  71.     rts
  72.  
  73. _GMSBase dc.l    0
  74.  
  75. GMSName     dc.b    "GMS:GPI/Master.GPI",0
  76.      even
  77.  
  78.